function dem_param = readDemPar(dem_par_path, varargin)

    dem_par_lines = readlines(dem_par_path);
    dem_proj = sscanf(dem_par_lines(3), 'DEM_projection:%s');
    data_format = sscanf(dem_par_lines(4), 'data_format:%s');
    width = sscanf(dem_par_lines(7), 'width:%d');
    nlines = sscanf(dem_par_lines(8), 'nlines:%d');
    corner_lat = sscanf(dem_par_lines(9), 'corner_lat:%f');  % 锚点在cell的中心点
    corner_lon = sscanf(dem_par_lines(10), 'corner_lon:%f'); % 锚点在cell的中心点
    post_lat = sscanf(dem_par_lines(11), 'post_lat:%f');
    post_lon = sscanf(dem_par_lines(12), 'post_lon:%f');
    ellipsoid_name = sscanf(dem_par_lines(14), 'ellipsoid_name: %6c');
    datum_name = sscanf(dem_par_lines(18), 'datum_name: %6c');

    if isequal(data_format, "REAL*4")
        data_format = 'single';
    elseif isequal(data_format, "INTEGER*4")
        data_format = 'int16';
    else
        error("invalid DataFormat: %s", data_format);
    end

    dem_param = struct('m_className', 'DEM-PARAM');
    dem_param.m_size_x = width;
    dem_param.m_size_y = nlines;
    dem_param.m_scale_x = post_lon;
    dem_param.m_scale_y = post_lat;
    % 将锚点放在cell的左上角
    % dem_param.m_origin_x = corner_lon - dem_param.m_scale_x / 2;
    % dem_param.m_origin_y = corner_lat - dem_param.m_scale_y / 2;
    dem_param.m_origin_x = corner_lon;
    dem_param.m_origin_y = corner_lat;

    % 计算右下角坐标
    dem_param.m_end_x = dem_param.m_origin_x + (dem_param.m_size_x - 1) * dem_param.m_scale_x;
    dem_param.m_end_y = dem_param.m_origin_y + (dem_param.m_size_y - 1) * dem_param.m_scale_y;
    
    % 读取投影、椭球、高程基准、数据类型
    if nargin >= 2 && varargin{1} == true
        dem_param.m_data_format = data_format;
        dem_param.m_dem_proj = dem_proj;
        dem_param.m_ellipsoid = ellipsoid_name;
        dem_param.m_datum = datum_name;
    end
end
